package com.yb.guigu.pick.product.controller;


import com.yb.guigu.pick.db.bean.PageRequest;
import com.yb.guigu.pick.product.entity.Category;
import com.yb.guigu.pick.product.service.ICategoryService;
import com.yb.guigu.pick.core.bean.GuiguResult;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 商品三级分类 前端控制器
 * </p>
 *
 * @author 姚兵
 * @since 2023-06-10
 */
@RestController
@RequestMapping("/category")
@AllArgsConstructor
public class CategoryController {

    ICategoryService categoryService;


    @PostMapping("/page")
    public GuiguResult page(@RequestBody PageRequest<Category> pageRequest){
        return categoryService.listPage(pageRequest);
    }
    @GetMapping("/remove/{id}")
    public GuiguResult page(@PathVariable Integer id){
        return GuiguResult.success(categoryService.removeById(id));
    }

    @PostMapping("/remove/batch")
    public GuiguResult page(@RequestBody List<Integer> ids){
        return GuiguResult.success(categoryService.removeBatchByIds(ids));
    }

    @GetMapping("/list")
    public GuiguResult list(){
        return GuiguResult.success(categoryService.list());
    }

}
